<?php
	function GetUrl($path)
	{
		$host=$_SERVER['SERVER_NAME'];
		$port=$_SERVER['SERVER_PORT'];
		if($port!="80")
		{
			$host=$host.":$port";
		}
		$uri=$_SERVER['REQUEST_URI'];
		$token=strtok($uri,"/");
		$i=0;
		while($token != false)
		{
			if($i==0)
			{
				$host=$host."/".$token;
				break;
			}
			$token=strtok("/");
		}
		$protocol="http";
		if(strstr($_SERVER['SERVER_PROTOCOL'],"HTTPS")!=false)
		{
			$protocol=$protocol."s";
		}
		
		$url=$protocol."://".$host."/".$path;
		return $url;
	}
?>